package com.lancer.designPattren.c01simpleFactory;

/**
 * 简单工厂模式
 * 计算方法工厂
 */
public class OpetationFactory {

    public static Operation CreateOpetation(String operate) throws Exception {
        Operation operation =  null;

        switch (operate){
            case "+":
                operation = new OperationAdd();
                break;
            case "-":
                operation = new OperationSub();
                break;
            case "*":
                operation = new OperationMul();
                break;
            case "/":
                operation = new OperationDiv();
                break;
            default:
                throw new Exception("无法识别的运算符");

        }
        return operation;
    }

}
